﻿using System.Collections.Generic;

namespace LxCore
{
    public class ExcuteCenter 
    {
        //待应用场景：比如某个定温度壁面，设置一次后不需要再设置，将命令打包为Action，在Step之后执行，然后自动清理


        public List<ExcuteBase> ExcuteAfterAll_Fixed = new List<ExcuteBase>();
        private Action AfterStepOnce;
        private Action AfterInitOnce;
        public void AddAfterStepOnce(Action action)
        {
            AfterStepOnce += action;
        }
        public void AddAfterInitOnce(Action action)
        {
            AfterInitOnce += action;
        }
        public void RunAfterInit()
        {
            AfterInitOnce?.Invoke();
            AfterInitOnce = null;
        }
        public void RunBeforeStep()
        {

        }
        public void RunAfterStep()
        {
            AfterStepOnce?.Invoke();
            AfterStepOnce = null;
        }
        public void ExcuteAfterAll()
        {
            foreach (var e in ExcuteAfterAll_Fixed)
            {
                e.Excute();
            }
        }
    }
}
